package edu.hawaii.halealohacli.command;

import static org.junit.Assert.assertTrue;
import javax.xml.datatype.XMLGregorianCalendar;
import org.junit.Test;
import org.wattdepot.client.WattDepotClient;
import org.wattdepot.resource.source.jaxb.Source;
import org.wattdepot.util.tstamp.Tstamp;

/**
 * A JUnit test class for the Command EnergySince.
 * @author Russell Vea
 * @author Yong Hong Hsu
 * @author David Wilkie
 */
public class TestEnergySince {

  /**
   * Tests EnergySince from the first day of this month.
   * @throws Exception if there's an error with the server.
   */
  @Test public void test() throws Exception {
    WattDepotClient client = new WattDepotClient("http://server.wattdepot.org:8190/wattdepot/");
    EnergySince test = new EnergySince();
    Source testSource = client.getSources().get(0);
    XMLGregorianCalendar testTimestamp = Tstamp.makeTimestamp();
    
    //set day to the day WattDepot was restored
    testTimestamp.setMonth(11);
    testTimestamp.setDay(23);
    testTimestamp.setHour(0);
    testTimestamp.setMinute(0);
    testTimestamp.setSecond(0);
    testTimestamp.setMillisecond(0);
    test.printResults(client, testSource, testTimestamp);
    assertTrue("Test to see if energy is greater than zero.", test.getEnergy() > 0.0);
  }
  
}
